<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Career extends ADMIN_Controller  {
	
	function __construct(){
		parent::__construct();
		$this->load->helper("url");
		$this->load->helper('form');
		$this->load->model("career_model");
		$this->load->model("profile_model");
		$this->load->library("pagination");
		$this->load->library('calendar');
		
	}
	
	public function index()
	{
			$this->showjob();
	}
	
	public function postjob() {
		$this->data['query'] = $this->profile_model->show_profile($this->session->userdata['userid']);
		$this->render_page('post_job_view');
		
	}
	
	public function viewjob($jobId = '') {
		if (!empty($jobId))
		{
			$this->data['query'] = $this->career_model->show_job($jobId);
			$this->render_page('admin_job_view');
		}
	}
	
	public function editjob($jobId = '') {
		if (!empty($jobId))
		{
			$this->data['query'] = $this->career_model->show_job($jobId);
			$this->render_page('admin_edit_job_view');
		}
	}
	
	public function editprocess($jobId = '') {
		$result = $this->career_model->edit_job($jobId);
		$this->viewjob($jobId);
	}
	
	public function process() {
		$result = $this->career_model->postjob();
		if($result)
			$this->showjob();
		else
			$this->postjob();
	}
	
	public function showjob() {
		$config = array();
		$config["base_url"] = base_url() . "index.php/admin/career/showjob";
		$config["total_rows"] = $this->career_model->record_count();
		$config["per_page"] = 15;
		$config["uri_segment"] = 3;
		
		$this->pagination->initialize($config);
		$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
		$this->data["results"] = $this->career_model->admin_show_all_jobs($config["per_page"], $page);
		if($config["total_rows"] > 15)
			$this->data["links"] = $this->pagination->create_links();
		$this->render_page('admin_show_job_view');
	}
	
	public function status($status = '') {
		if($status == 'app')
		{
			$this->session->set_userdata('status','app');
			redirect('admin/career/showjob');
		}
		else if($status == 'uapp')
		{
			$this->session->set_userdata('status','uapp');
			redirect('admin/career/showjob');
		}
		else if($status == 'all')
		{
			$this->session->unset_userdata('status');
			redirect('admin/career/showjob');
		}
	}
	
}

/* End of file index.php */
/* Location: ./application/controllers/welcome.php */